package com.allianz.webapps.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.allianz.webapps.https.interfaces.appGetDetail.AppGetDetail;
import com.allianz.webapps.orderspojo.App;
import com.allianz.webapps.orderspojo.AppBase;
import com.fasterxml.jackson.databind.ObjectMapper;

@Controller
@RequestMapping(value="main")
public class AppGetDetailController {

	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private AppGetDetail appGetDetail;
	
	/**
	 * 编辑的请求
	 */
	@RequestMapping(value="appGetDetail")
	@ResponseBody
	public App appGetDetail(@RequestParam(value="jsonParam") String jsonParam,HttpServletRequest request,HttpServletResponse response)
			throws Exception{
		AppBase appBase=(AppBase)objectMapper.readValue(jsonParam, AppBase.class);
		String body=appGetDetail.requestParam(appBase);
		JSONObject json=new JSONObject(body);
		App app=null;
		String body1="";
		if (json.get("Body").equals(null)) {
			body1="";
		}else{
			body1=json.getString("Body");
			app=objectMapper.readValue(body1, App.class);
		}
		return app;
	}
	
}
